package com.mxl.service.cashorder.rule;

import javax.annotation.Resource;

import com.mxl.common.helper.ResponseErrorCode;
import com.mxl.common.rule.AbstractRule;
import com.mxl.dao.cashorder.impl.PurchaseOrderDaoImpl;
import com.mxl.service.cashorder.dto.CashOrderRequest;

/**
 * 检查卡密是否已经使用
 * 
 * @author Administrator
 * 
 */
public class CheckCardPwdEffective extends AbstractRule {
	@Resource(name = "purchaseOrderDao")
	private PurchaseOrderDaoImpl purchaseOrderDao;

	protected boolean makeDecision(Object obj) throws Exception {
		CashOrderRequest c = (CashOrderRequest) obj;
		if (purchaseOrderDao.getCardNoUse(c.getCardNo())) {
			c.setMsgId(ResponseErrorCode.CARDNO_REPEAT.getValue());
			return false;
		}
		if (purchaseOrderDao.getCardPwdUse(c.getCardPwd())) {
			c.setMsgId(ResponseErrorCode.CARDPWD_REPEAT.getValue());
			return false;
		}
		return true;
	}

}
